<template>
  <header class="header">
    <h1>任务列表</h1>
    <input
      @keyup.enter="add"
      v-model="todoname"
      class="new-todo"
      placeholder="请输入要做的事情"
      autofocus
    />
  </header>
</template>
  
  <script>
export default {
  data() {
    return {
      todoname: "",
    };
  },
  methods: {
    add() {
      // 方法、数据项，如果写到JS中，需要加 this.
      this.$emit("add", this.todoname);
      this.todoname = "";
    },
  },
};
</script>
  
  <style>
</style>